/**
 *
 */
package com.et114.core.dao;


import com.et114.core.dao.vo.BaseVO;
import com.et114.core.exception.CheckException;

import java.util.List;

/**
 * @author guanhw
 */
public interface IBaseDAO {
	/**
	 * 根据条件返回实体bean
	 * JuntiTest test = new JunitTest();
	 * test.setId(1);
	 * test = dao.load(test,"getJunitTest");
	 * 在配置文件中为如下定义
	 *   <select id="getJunitTest"  resultMap="junittest">
     *      select *  from junittest where junittest.id=#id#
     *   </select>
	 * @param entity 实体bean
	 * @param method sql唯一标识号，对应ibatis配置文件中定义的sql语句id号
	 * @return 实体bean
	 * @throws DataAccessException
	 */
	public BaseVO load( BaseVO entity , String method ) throws CheckException;
    /**
     * 根据条件删除记录
     * JuntiTest test = new JunitTest();
	 * test.setId(1);
	 * dao.delete(test,"deleteJunitTest");
	 * 在配置文件中为如下定义
	 *   <delete id="deleteJunitTest" parameterClass="junittest">
     *      delete from junittest where id = #id#
     *   </delete>
     * @param entity 实体bean
     * @param method sql唯一标识
     * @throws DataAccessException
     */
	public int delete( BaseVO entity , String method ) throws CheckException;
    /**
     * 根据条件更新记录
     * JuntiTest test = new JunitTest();
	 * test.setId(1);
	 * test = dao.load(test,"getJunitTest");
	 * test.setName("newName");
	 * dao.update(test,"updateJunitTest");
	 * 在配置文件中为如下定义
	 *   <update id="updateJunitTest" parameterClass="junittest">
     *      update junittest set name=#name#,remark=#remark# where id=#id#
     *   </update>
     * @param entity 实体bean
     * @param method sql唯一标识，对应ibatis配置文件中定义的sql语句id号
     * @throws DataAccessException
     */
	public int update( BaseVO entity , String method ) throws CheckException;
    /**
     * 插入新记录
     * JuntiTest test = new JunitTest();
	 * test.setId(1);
	 * test.setName("newName");
	 * test.setRemark("newRemark");
	 * dao.insert(test,"insertJunitTest");
	 * 在配置文件中为如下定义
	 *   <insert id="insertJunitTest" parameterClass="junittest">
     *      insert into junittest (id,name,remark) values (#id#,#name#,#remark#)
     *  </insert>
     * @param entity 实体bean
     * @param method sql唯一标识
     * @throws DataAccessException
     */
	public Object insert( BaseVO entity , String method ) throws CheckException;
    /**
     * 获取sequence id
     * Integer id = dao.getSequence("S_JUNIT");
     * @param seqid   Sequence 名称
     * @return Integer id号
     * @throws DataAccessException
     */
//	public Integer getSequence( String seqid ) throws CheckException;
    /**
     * 查询功能（无分页）
     * JunitTest test = new JunitTest();
     * test.setName("test");
     * dao.queryList(test,"listJunitTest");
     * 在配置文件中定义如下
     * <select id="listJunitTest" parameterClass="junittest" resultClass="junittest">
     *   select *  from junittest
     *   <dynamic prepend="WHERE">
     *   <isNotEmpty prepend="AND" property="name">
     *   (name like '%$name$%')
     *   </isNotEmpty>
     *   </dynamic>
     *</select>
     * @param entity  实体bean
     * @param method  sql唯一标识，对应ibatis配置文件中定义的sql语句id号
     * @return List   实体bean列表
     * @throws DataAccessException
     */
	public List queryList( BaseVO entity , String method ) throws CheckException;
    /**
     * 查询功能（分页）
     * JunitTest test = new JunitTest();
     * test.setName("test");
     * dao.queryList(test,10,2,"pagelistJunitTest");
     * 在配置文件中定义如下
     * <select id="pagelistJunitTest" parameterClass="junittest" resultMap="junittest">
     *    select * from (select row_.* ,rownum rownum_ from (
     *    select *  from junittest
     *   <dynamic prepend="WHERE">
     *   <isNotEmpty prepend="AND" property="name">
     *   (name like '%$name$%')
     *   </isNotEmpty>
     *   </dynamic>
     *    ) row_) where rownum_>#firstrow# and #lastrow#>rownum_
     * </select>
     * 在分页功能中，必须在配置文件中定义一个以count+method为唯一标识的sql，用于计算总页数,具体定义参照getCount方法
     * @param entity  实体bean
     * @param pagenum 每页显示记录数
     * @param npage   当前页号
     * @param method  sql唯一标识，对应ibatis配置文件中定义的sql语句id号
     * @return DataList 分页功能列表
     * @throws DataAccessException
     */
//	public DataList queryList(Entity entity, int pagenum, int npage,
//			String method) throws CheckException;
	/**
	 * 计算总数方法
	 * @param entity 实体bean
	 * @param method sql唯一标识，对应ibatis配置文件中定义的sql语句id号
	 * JunitTest test = new JunitTest();
	 * test.setName("test");
	 * Integer count = dao.getCount(test,"");
	 * <select id="countpagelistJunitTest" resultClass="java.lang.Integer">
     *   select count(*) count  from junittest
     *  <dynamic prepend="WHERE">
     *  <isNotEmpty prepend="AND" property="name">
     *  (name like '%$name$%')
     * </isNotEmpty>
     * </dynamic>
     *</select>
	 * @return
	 * @throws DataAccessException
	 */
	public Long getCount( BaseVO entity , String method ) throws CheckException;
	public Long getCount( Object entity , String method ) throws CheckException ;
	/**
	 * 获取用户的语言标识
	 * @return
	 */
	public String getUserLanguage();
	/**
	 * 更新需要并发处理的表
	 * @param entity 实体bean
	 * @param updmethod 更新sql唯一标识，对应ibatis配置文件中定义的sql语句id号
	 * @param selectmethod 查询sql唯一标识，对应ibatis配置文件中定义的sql语句id号
	 * JunitTest test = getTest();
	 * test.setName("test");
	 * int updrows = dao.updateForIntercurrent(test,"update","select");
	 * <update id="update" resultClass="java.lang.Integer">
	 *   update junittest set id=#id# where id=#id#
	 * </update>
	 * <select id="countpagelistJunitTest" resultClass="java.lang.Integer">
     *   select recordflag from junittest where id=#id#
	 * @return
	 * @throws DataAccessException
	 * @throws CheckedException
	 */
	public int updateForIntercurrent( BaseVO entity , String updmethod , String selectmethod ) throws CheckException;
}
